package zut.edu.cs.network.practice9;

public class Person implements Comparable<Object> {
	Name name;

	public Name getName() {
		return name;
	}

	public void setName(Name name) {
		this.name = name;
	}

	public Person(Name name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return name.getFullName();
	}

	public boolean equals(Object obj) {
		if(obj instanceof Person) {
			Person person = (Person) obj;
			if(this.name==person.name)
				return true;
		}
		return false;		
	}

	@Override
	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		int result=0;
		if(o instanceof Person) {
			Person p=(Person)o;
			result=this.getName().getLastName().compareTo(p.getName().getLastName());
			if(result==0) {
				result=this.getName().getFirstName().compareTo(p.getName().getFirstName());
			}
			if(result==0) {
				result=this.getName().getMi()-p.getName().getMi();
			}
		}
		return result;
	}

}
